package com.jason.config;


import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;


/**
 * @author itguang
 * @create 2018-01-04 13:36
 **/
@Configuration
@EnableSwagger2
public class SwaggerConfig {

    @Bean
    public Docket petApi() {
        Docket docket = new Docket(DocumentationType.SWAGGER_2)
                .select()
                //添加所有Controller
                .apis(RequestHandlerSelectors.basePackage("com.jason"))
                //.apis(RequestHandlerSelectors.withClassAnnotation(Controller.class))
                .paths(PathSelectors.any())
                .build();

        //    Api的一些描述信息
        ApiInfo apiInfo = new ApiInfoBuilder()
                .title("基于SpringBoot的秒杀系统")
                .description("符合RESTful风格的Api")
                .contact(new Contact("jason", "http://www.jason.top", "zhuky9527@qq.com"))
                .version("v1.0")
                .build();
        docket.apiInfo(apiInfo);

        return docket;

    }
}
